#ifndef SIMPLE_GEOM_BOX_HPP
#define SIMPLE_GEOM_BOX_HPP

#include "vector.hpp"
#include "simple/support/range.hpp"

namespace simple::geom
{

	template <typename Type>
	struct segment
	{
		Type size, position;

		using range = support::range<Type>;

		[[nodiscard]]
		constexpr operator range() const { return to_range(); }

		[[nodiscard]]
		constexpr auto to_range() const
		{
			return range{position, position + size};
		}

		[[nodiscard]]
		constexpr bool operator==(const segment& one) const = default;

	};

	template <typename T> segment(T, T) -> segment<T>;

	template <typename Type, typename AnchorType = Type>
	struct anchored_segment : public segment<Type>
	{
		using base = segment<Type>;
		AnchorType anchor;

		[[nodiscard]]
		// NOTE: maybe return range<common type <Type, AnchorType>> if range<Type> doesn't work??
		// gotta have an actual use case to make it worth it though
		constexpr operator typename base::range() const { return to_range(); }

		[[nodiscard]]
		constexpr auto to_range() const
		{
			auto lower = this->position - anchor * this->size;
			return support::range{lower, lower + this->size};
		}

		[[nodiscard]]
		constexpr bool operator==(const anchored_segment& one) const = default;

		[[nodiscard]]
		constexpr bool operator==(const base& one) const = delete;
	};

	template <typename Coordinate, size_t Dimensions = 2>
	using vector_segment = segment<vector<Coordinate, Dimensions>>;

	template <typename Coordinate, size_t Dimensions = 2, typename Anchor = Coordinate>
	using anchored_vector_segment = anchored_segment<vector<Coordinate, Dimensions>, vector<Anchor, Dimensions>>;

} // namespace simple::geom

#endif /* end of include guard */
